/*
 * Plot.hpp
 *
 * Copyright 2012 Pieter Agten
 *
 * This file is part of tltgen.
 *
 * tltgen is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * tltgen is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with tltgen.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   Plot.hpp
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   29 dec 2012
 */

#ifndef PLOT_HPP
#define PLOT_HPP

#include "wxPLplotwindow.h"

#include <boost/tuple/tuple.hpp>
#include <boost/signals2.hpp>

using boost::tuple;

namespace tltgen {

  class Plot {
  public:
    virtual ~Plot();

    virtual std::string getTitle() const = 0;

    virtual unsigned int getNbDatasets() const = 0;
    virtual bool isValidDatasetIndex(unsigned int i) const {
      return 0 <= i && i < getNbDatasets();
    }
    virtual std::string getDatasetName(unsigned int i) const = 0;
    virtual void plotViewport(wxPLplotstream *pls) = 0;
    virtual void plotDataset(wxPLplotstream *pls, unsigned int i) = 0;

    virtual tuple<PLFLT, PLFLT> getXBounds() const = 0;
    virtual void setXBounds(PLFLT min, PLFLT max, bool signal = true) = 0;
    virtual void setXBoundsAuto(bool signal = true) = 0;
    virtual bool isXBoundsAuto() const = 0;
    virtual bool isValidXBounds(PLFLT min, PLFLT max) const = 0;

    virtual tuple<PLFLT, PLFLT> getYBounds() const = 0;    
    virtual void setYBounds(PLFLT min, PLFLT max, bool signal = true) = 0;
    virtual void setYBoundsAuto(bool signal = true) = 0;
    virtual bool isYBoundsAuto() const = 0;
    virtual bool isValidYBounds(PLFLT min, PLFLT max) const = 0;

    virtual PLFLT getYValue(unsigned int i, PLFLT x) const = 0;

    enum NbDatasetsChangedEvent {
      DATASET_ADDED,
      DATASET_REMOVED,
    };

    typedef boost::signals2::signal<void ()> DataChangedSignal;
    typedef DataChangedSignal::slot_type DataChangedSlot;
    typedef boost::signals2::signal<void (NbDatasetsChangedEvent, unsigned int)> NbDatasetsChangedSignal;
    typedef NbDatasetsChangedSignal::slot_type NbDatasetsChangedSlot;
    virtual boost::signals2::connection connectDataChangedObserver(const DataChangedSlot &slot) = 0;
    virtual boost::signals2::connection connectNbDatasetsChangedObserver(const NbDatasetsChangedSlot &slot) = 0;
  };

}

#endif
